﻿/*
Copyright (c) 2011 <a href="http://www.gutgames.com">James Craig</a>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/

#region Usings
using System;

#endregion

namespace HaterAide.Mappings
{
    /// <summary>
    /// Used to hold information about a property
    /// </summary>
    public class Attribute
    {
        #region Constructor

        /// <summary>
        /// Constructor
        /// </summary>
        public Attribute()
        {
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Property name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Property type
        /// </summary>
        public Type Type { get; set; }

        /// <summary>
        /// The mapping type
        /// </summary>
        public AttributeType MappingType { get; set; }

        /// <summary>
        /// The table the property is mapped to (used in many to many and many to one)
        /// </summary>
        public string MappedTable { get; set; }

        /// <summary>
        /// The name of the field in the derived type
        /// </summary>
        public string DerivedFieldName { get; set; }

        /// <summary>
        /// Determines if we cascade a save
        /// </summary>
        public bool Cascade { get; set; }

        /// <summary>
        /// Max length of a string (only used for strings)
        /// </summary>
        public int Length { get; set; }

        /// <summary>
        /// Determines whether we auto increment the item or not (used for IDs, but currently ignored)
        /// </summary>
        public bool AutoIncrement { get; set; }

        /// <summary>
        /// Associated table or column (if one exists, null otherwise)
        /// </summary>
        public HaterAide.SQL.DataClasses.Interfaces.IEntity AssociatedTable { get; set; }

        #endregion
    }

    #region Enums

    /// <summary>
    /// Attribute type
    /// </summary>
    public enum AttributeType
    {
        ID = 0,
        Reference,
        Map,
        ManyToOne,
        ManyToMany
    }

    #endregion
}
